﻿package {
	import Box2D.Dynamics.*;
	import Box2D.Collision.*;
	import Box2D.Collision.Shapes.*;
	import Box2D.Common.Math.*;
	import Box2D.Dynamics.Joints.*;
	
	public class edge {
		public var edgeStart:b2Vec2;
		public var edgeEnd:b2Vec2;
		public var timesTouched:int;
		
		public function edge(edgeArray:Array, touches:int = 0):void {
			edgeStart = edgeArray[0];
			edgeEnd = edgeArray[1];
			timesTouched = touches;
		}
		
		public function getEdge():Array {
			var returnArray:Array = new Array();
			returnArray = [edgeStart, edgeEnd];
			return returnArray;
		}
		public function getTimesTouched():int {
			return timesTouched;
		}
		public function setEdge(edgeBody:Array) {
			edgeStart = edgeBody[0];
			edgeEnd = edgeBody[1];
		}
		public function setTimesTouched(timesTouched:int) {
			this.timesTouched = timesTouched;
		}
		public function incrementTimesTouched() {
			this.timesTouched += 1;
		}
		public function toString():String {
			if (timesTouched > 0) {
				return "Edge at " + edgeStart.x + ", " +
				edgeStart.y + " has been touched";
			} else {
				return "Edge at " + edgeStart.x + ", " +
				edgeStart.y + " has not been touched";
			}
		}
		
		public function equals(testEdge:edge):Boolean {
			if (this.edgeStart.x == testEdge.edgeStart.x &&
				this.edgeStart.y == testEdge.edgeStart.y &&
				this.edgeEnd.x == testEdge.edgeEnd.x &&
				this.edgeEnd.y == testEdge.edgeEnd.y &&
				this.getTimesTouched() == testEdge.getTimesTouched()
				) {
					return true;
			} else {
				return false;
			}
		}
	}
}